package com.dong.redis;


import redis.clients.jedis.Jedis;
import redis.clients.jedis.Tuple;

import java.util.List;
import java.util.Set;

/**
 * @author: dzj
 * @date 2018/8/20-15:01
 */
public class JedisTest {
    public static void main(String[] args) throws InterruptedException {

        Jedis jedis = new Jedis("123.206.47.196",6379);
   //     Jedis jedis = new Jedis("10.0.109.221",6379);
        jedis.select(3);
        String ping = jedis.ping();
        System.out.println(ping);
        jedis.set("hello","world");
        Thread.sleep(200);
        String hello = jedis.get("hello");
        System.out.println(hello);
        Long counter = jedis.incr("counter");
        System.out.println("counter");
        jedis.rpush("mylist","1");
        jedis.rpush("mylist","2");
        jedis.rpush("mylist","3");
        List<String> mylist = jedis.lrange("mylist", 0, -1);
        mylist.stream().forEach(item -> System.out.println(item));
        jedis.sadd("myset","a");
        jedis.sadd("myset","b");
        jedis.sadd("myset","c");
        Set<String> myset = jedis.smembers("myset");
        myset.stream().forEach(item-> System.out.println(item));
        jedis.zadd("myzset",99,"aa");
        jedis.zadd("myzset",33,"bb");
        jedis.zadd("myzset",66,"cc");
        Set<Tuple> myzset = jedis.zrangeWithScores("myzset", 0, -1);
        myzset.stream().forEach(item-> System.out.println(item));
        jedis.close();
    }





}
